
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>xx商城后台 - 登录</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.min.css" rel="stylesheet">

    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
   
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>

                <!-- <h1 class="logo-name">商城注册</h1> -->

            </div>
            <h2>欢迎使用 xx商城</h2>
                <div class="form-group">
                    <input type="email" class="form-control" placeholder="用户名" required="">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" placeholder="密码" required="">
                </div>
                <button type="submit" class="btn btn-primary block full-width m-b">登 录</button>


                <p class="text-muted text-center"> <a href="#"><small>忘记密码了？</small></a> | <a href="register.html">注册一个新账号</a>
                </p>

        </div>
    </div>
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script>
        // let username = $('input').eq(0).val();
        // let password = $('input').eq(1).val();
        $('button').click(function(){
            console.log($('input').eq(0).val(),$('input').eq(1).val());
            //console.log(username,password);
            let url = `http://jx.xuzhixiang.top/ap/api/login.php?username=${$('input').eq(0).val()}&password=${$('input').eq(1).val()}`;
        $.ajax({
            url:url,
            type:'get',
            data:{
                username:$('input').eq(0).val(),
                password:$('input').eq(1).val()
            }
        }).then(res =>{
            console.log(res);
            if(res.code == 1){
                alert(res.msg);
                localStorage.setItem('username',res.data.username);
                localStorage.setItem('id',res.data.id);
                localStorage.setItem('token',res.data.token);
                location.href = 'index.html';
            }
        });
        });
    </script>
</body>

</html>
